package com.zhangzhan.gulimallware.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhangzhan.gulimallware.entity.WareSkuEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 商品库存
 * 
 * @author zhangzhan
 * @email sunlightcs@gmail.com
 * @date 2024-06-18 23:32:09
 */
@Mapper
public interface WareSkuDao extends BaseMapper<WareSkuEntity> {


    Integer updateStockLock(@Param("wareId") Long wareId, @Param("skuId") Long skuId, @Param("count") Integer count);

    @Select("select * from wms_ware_sku where sku_id = #{skuId}  and  stock - stock_locked > 0")
    List<WareSkuEntity> getSkuInventory(@Param("skuId") Long skuId);


    Integer unLock(@Param("wareId") Long wareId, @Param("skuId") Long skuId, @Param("count") Integer count);
}
